package com.sfzd5.AnswerSheetJavaTest;

import com.sfzd5.AnswerSheetHelper.inter.IBitmap;
import com.sfzd5.exam.helplibrary.WindowsDrawStringEventListener;
import org.bytedeco.javacpp.opencv_core.Mat;
import org.bytedeco.javacv.Java2DFrameUtils;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import static java.awt.image.BufferedImage.TYPE_BYTE_GRAY;

public class Bitmap implements IBitmap{

    private BufferedImage img;

    public Bitmap(File file) throws IOException {
        this.img = ImageIO.read(file);
    }

    public Bitmap(BufferedImage img){
        this.img = img;
    }

    public Bitmap(Mat mat) {
        setBitmap(mat);
    }

    public BufferedImage getImg() {
        return img;
    }

    @Override
    public Mat toMat() {
        return Java2DFrameUtils.toMat(img);
    }

    @Override
    public void setBitmap(Mat mat) {
        this.img = Java2DFrameUtils.toBufferedImage(mat);
    }
}
